import request from '@/utils/request'

// 微服务列表
export function sysServiceList(params) {
  return request.get('/system/sysService/list', {params})
}

export function sysServiceBusinessList() {
  return request.get(`/system/sysService/getListByRole`);
}

// 根据角色id获取微服务id
export function selectServiceListByRoleId(roleId) {
  return request.get(`/system/sysService/selectServiceListByRoleId/${roleId}`)
}

// 查询角色列表
export function listRole(params) {
  return request.get('/system/role/list', {params})
}

// 查询角色详细
export function getRole(roleId) {
  return request.get(`/system/role/${roleId}`)
}

// 新增角色
export function addRole(data) {
  return request.post('/system/role', data)
}

// 修改角色
export function updateRole(data) {
  return request.put('/system/role', data)
}

// 角色数据权限
export function dataScope(data) {
  return request.put('/system/role/dataScope', data)
}

// 角色状态修改
export function changeRoleStatus(roleId, status) {
  const data = {
    id: roleId,
    status
  }
  return request.put('/system/role/changeStatus',data)
}

// 删除角色
export function delRole(roleId) {
  return request.delete(`/system/role/${roleId}`)
}

// 查询角色已授权用户列表
export function allocatedUserList(params) {
  return request.get('/system/role/authUser/allocatedList',{params})
}

// 查询角色未授权用户列表
export function unallocatedUserList(params) {
  return request.get('/system/role/authUser/unallocatedList',{params})
}

// 取消用户授权角色
export function authUserCancel(data) {
  return request.put('/system/role/authUser/cancel',data)
}

// 批量取消用户授权角色
export function authUserCancelAll(data) {
  return request.put('/system/role/authUser/cancelAll', data);
}

// 授权用户选择
export function authUserSelectAll(data) {
  return request.put('/system/role/authUser/selectAll', data);
}
